import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login'
import Layout from '@/views/Layout' // 首页
import Cuisine from '@/views/cuisine' // 菜品
import Addmenu from '@/views/addmenu' // 增加菜谱
import Addcuisine from '@/views/addcuisine' // 菜品菜品

// import Aside from '@/views/aside'

// import { Aside } from 'element-ui'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: '/',
    redirect: '/Login'
  },
  {
    path: '/Login',
    name: '登录',
    component: Login
  },
  {
    path: '/Layout',
    name: '主页',
    component: Layout,
    children: [
      {
        path: '/cuisine',
        name: '菜品库',
        component: Cuisine,
        meta: { istoken: true }, // 判断是否有token,
        children: [
          {
            path: '/cuisine/addmenu',
            name: '增加菜谱',
            component: Addmenu,
            meta: { istoken: true } // 判断是否有token,
          },
          {
            path: '/cuisine/addcuisine',
            name: '增加菜品',
            component: Addcuisine,
            meta: { istoken: true } // 判断是否有token,
          }
        ]
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL, // 默认路由配置模式 在config里面配置
  routes
})

// 路由前置守卫
router.beforeEach((to, from, next) => {
  next()
})
// 路由后置守卫
router.afterEach((to, from) => {})

export default router
